#ifndef COMMON__H
#define COMMON__H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

//#define DEBUG
//#define LESS
//#define RELOP_DETAIL

#ifdef DEBUG
#define DBG_printf(...) printf(__VA_ARGS__)
#else 
#define DBG_printf(...) ((void)0)
#endif

#define LOG(fmt,...) DBG_printf(fmt "\n",##__VA_ARGS__)

#define Assert(cond,fmt,...) \
    do{\
        if(!(cond)){\
            LOG(fmt,##__VA_ARGS__);\
        }\
        assert(cond);\
    } while (0)
    
//util.c
char * str_maker(const char * fmt,...);
unsigned hash(const char * ch);
void print_error(char * type,int lineno,char * msg);
unsigned new_var();
unsigned new_label();
enum{LE,GT,GE,LT,NE,EQ};

#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))

enum Mysymbol{
  CYF_Program = 33,                   /* Program  */
  CYF_ExtDefList = 34,                /* ExtDefList  */
  CYF_ExtDef = 35,                    /* ExtDef  */
  CYF_ExtDecList = 36,                /* ExtDecList  */
  CYF_Specifier = 37,                 /* Specifier  */
  CYF_StructSpecifier = 38,           /* StructSpecifier  */
  CYF_OptTag = 39,                    /* OptTag  */
  CYF_Tag = 40,                       /* Tag  */
  CYF_VarDec = 41,                    /* VarDec  */
  CYF_FunDec = 42,                    /* FunDec  */
  CYF_VarList = 43,                   /* VarList  */
  CYF_ParamDec = 44,                  /* ParamDec  */
  CYF_CompSt = 45,                    /* CompSt  */
  CYF_StmtList = 46,                  /* StmtList  */
  CYF_Stmt = 47,                      /* Stmt  */
  CYF_DefList = 48,                   /* DefList  */
  CYF_Def = 49,                       /* Def  */
  CYF_DecList = 50,                   /* DecList  */
  CYF_Dec = 51,                       /* Dec  */
  CYF_Exp = 52,                       /* Exp  */
  CYF_Args = 53                       /* Args  */
};

extern int flex_error,syntax_error,err;

#endif
